package springapp.web;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import springapp.service.UserRegistrationForm;

@Controller
@SessionAttributes
public class UserRegistrationController {
    
	@RequestMapping(value = "/registerUser.htm", method = RequestMethod.POST)
    public String registerUser(@ModelAttribute("user")
                            UserRegistrationForm user, BindingResult result) {

		System.out.println("Registration. First Name:" + user.getFirstname() +
                    "Last Name:" + user.getLastname());
 
        return "hello";
    }
 
    @RequestMapping("/userRegistration.htm")
    public ModelAndView showUserForm() {
 
        return new ModelAndView("registeruser", "command", new UserRegistrationForm());
    }
}
